1. Field of the Invention
The present invention relates to the field of instrumenting and monitoring of application programs and, in particular, to a system and method instrumenting code for in-production monitoring.
2. Description of the Related Art
A conventional technique for instrumenting the code of an application program written in the object-oriented language, Java, requires a developer to construct a JavaBean object and then construct a dynamic management “bean” (MBean) that references the JavaBean object using Java management extensions (JMX) application programming interfaces (APIs).
The state of a JavaBean object is stored in variables and the behaviors of the JavaBean object are implemented with methods. Variables are named records in which you can store data for later use. Methods are named pieces of code that implement behaviors the JavaBean object is configured to perform. In object-oriented terminology, each implementation or manifestation of a JavaBean object is an “instance” of the generic class of the object. Each instance of the object has specific state associated with that particular instance, but every instance has the same methods defining its behavior. When created, each JavaBean object has memory allocated to it to hold its instance variables, i.e., the state for the object. Once the JavaBean object is created, the instance methods of the JavaBean may be called to execute the JavaBean object. The JavaBean object exposes one or more specific properties of the application program.
An MBean represents a resource to be managed, such as an application, device or service, and has a management interface consisting of the named and typed attributes that can be read and written, the named and typed operations that can be invoked, and the typed notifications that can be emitted by the MBean. A management tool may be configured to monitor the MBean to change settings, perform an administrative action, or to gather metrics related to the application program. A dynamic MBean is an MBean that defines its management interface at runtime.
An MBean may have an attribute representing a latency property of a calculation performed by the application program. The MBean may be configured to capture timestamps of the property exposed by the JavaBean and a JMX server may be configured to monitor the captured timestamps. In another example, an MBean representing an application program's configuration may have attributes representing the different configuration parameters, such as a cache size. Reading the Cachesize attribute of the MBean returns the current size of the cache. Writing the Cachesize attribute updates the size of the cache, potentially changing the behavior of the running application.
An MBean must be registered in a core managed object server, such as a JMX server before the MBean can be used. An MBean server acts as a management agent, runs on most devices enabled for the Java programming language, and is a repository of MBeans. Each MBean is registered with a unique name within the JMX server. Other objects or application programs do not access an MBean directly, but rather access the MBean by name through the JMX server.
FIG. 1 is a flowchart 100 of method steps describing the operation of a prior art technique for instrumenting code. At step 105 the JavaBean instance is constructed by a developer. At step 110 the developer constructs the dynamic MBean referencing the JavaBean. Steps 105 and 110 may be performed in parallel. At step 115 the developer registers the MBean with a JMX server. The JMX server may then monitor the instrumented application program and at step 120 execution of the application program continues. Importantly, the JMX server interactions to monitor the instrumented application program are performed on the main execution thread. Consequently, the interactions may result in reduced performance of the main execution thread, i.e., the application program. While a reduction in performance may not present a problem when the application program is executed for debug or quality assurance (QA) purposes, a reduction in performance does present a problem when in-production monitoring of the application program is performed.
As the foregoing illustrates, there is a need in the art for an improved technique of instrumenting code for in-production monitoring.